<?php
/**
 * Created by Allen.
 * Date: 15-12-03
 * 节点模型
 */

class Fora_log_model extends HS_Model {

	//添加
    public function addForaLog($data)
    {
        if ($this->add($data))
        {
            return $this->db->insert_id();
        }
    }
    
    //获取单个
    public function checkForaLog($where=array())
    {
    	return $this->where($where)->order_by('id desc')->find();
    }
    //获取单个
    public function checkForaLogJoin($where=array())
    {
        return $this->select('fora_log.*,fora.name as fora_name,fora.code as fora_code,fora.status as fora_status ,fora.num as fora_num')->join('fora','fora_log.fora_id = fora.id')->where($where)->order_by('fora_log.id desc')->find();
    }
    //编辑
    public function editForaLog($where,$data)
    {
        return $this->where($where)->edit($data);
    }
    
    //获取结果集
    public function getForaLogList($where=array(), $limit='20', $offset='0', $order_by='id desc')
    {
    	return $this->where($where)->limit($limit, $offset)->order_by($order_by)->find_all();
    }
    //获取单个
    public function getForaLogJoinAll($where=array())
    {
        return $this->select('fora_log.*,fora.name as fora_name,fora.code as fora_code,fora.status as fora_status ,fora.num as fora_num')->join('fora','fora_log.fora_id = fora.id')->where($where)->order_by('fora_log.id desc')->find_all();
    }
    //获取全部结果集，用于表格导出
    public function getForaLogAll($where=array(), $order_by='id desc')
    {
    	return $this->where($where)->order_by($order_by)->find_all();
    }
    
    //计算行数
    public function getCount($where = array())
    {
    	return $this->where($where)->count();
    }
    
    //删除
    public function deleteForaLog($where)
    {
    	return $this->where($where)->delete();
    }
} 